# Maintainer: Drew DeVault <sir@cmpwn.com>
# TODO: This package could be improved if Alpine had better support for
# cross-compiling with a better standardized and broader set of binutils
# and gcc packages.
pkgname=hare
pkgver="0_git20220611"
_commit=01aaa1c2b5f5d91db545095b22b22f4d352fc83d
pkgrel=0
pkgdesc="The Hare systems programming language"
url="https://harelang.org"
# riscv64: FTBFS: Abort: ./os/exec/cmd.ha:79:1: execution reached unreachable code (compiler bug)
# Caused by qemu-user, see https://gitlab.com/qemu-project/qemu/-/issues/1007
arch="x86_64 aarch64"
license="MPL-2.0 AND GPL-3.0-only"
depends="qbe harec binutils"
makedepends="scdoc"
subpackages="$pkgname-doc"
source="
	$pkgname-$_commit.tar.gz::https://git.sr.ht/~sircmpwn/hare/archive/$_commit.tar.gz
	config.aarch64.mk
	config.riscv64.mk
	config.x86_64.mk
"
builddir="$srcdir/$pkgname-$_commit"

build() {
	cp "$srcdir"/config.$CARCH.mk ./config.mk
	export VERSION="dev+$(echo "$_commit" | cut -c-7)"
	export LOCALVER=alpine
	make -j1 # XXX: parallel build driver builds are broken
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
8163f8a3943f48c0a86d72de0b402a74dca7badfe6379e1fda5cbce127e1087506204a01b83d5bba4a126fe91ddb2c917b575b1a110816ee930342c606893009  hare-01aaa1c2b5f5d91db545095b22b22f4d352fc83d.tar.gz
129189cbc86e1ee0ae5c81a12b2797f36b1a9ed742a81496fff14f8527ef6fe4881a261c2156a5bafcaeaf4a692e3cf8b27c473339676e65479e6f3546a3ee99  config.aarch64.mk
96280a82594b19ec8972946c89fa0f0b9d0e89cc517e6476ace4be8adc66be1d631d75172d36261e9c9414b0e3453be59dd7b4b0abf3735d182c28005dc5eee3  config.riscv64.mk
ad724530acea8377fd9372af416d467470497a4aa80a0405d1d4a9b6ddce609485549ffd31426884fa277b8dcab279288498413fddc41dc23ea24ad30bab224e  config.x86_64.mk
"
